﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manager_Nguoidung_Controls_UC_Nguoiquanly : System.Web.UI.UserControl
{
    BUS_Accounts accounts = new BUS_Accounts();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }
    public void LoadData()
    {
        gvQuanly.DataSource = accounts.Accounts_GetByAll();
        gvQuanly.DataBind();
    }
    public string Trangthai(bool tr)
    {
        
        if (tr)
        {
            return "Hoạt động";
        }
        else
        {
            return "Đã khóa";
        }
    }
    protected void gvQuanly_RowCommand(object sender, GridViewCommandEventArgs e)
    {

        if (e.CommandName == "Chitiet")
        {
            Response.Redirect("Chitietnguoidung.aspx?quanly="+e.CommandArgument);
        }
        //if(e.CommandName == "Xoa")
        //{
        //    accounts.Accounts_Delete(e.CommandArgument.ToString());
        //}
    }
    protected void btnTimkiem_Click(object sender, EventArgs e)
    {
        var dt = accounts.Accounts_GetByTop(0, "UserName like '%" + txtUserName.Text + "%'and Mail like '%" + txtEmail.Text + "%'and FullName like '%" + txtFullName.Text + "%' and Address like '%" + txtAddress.Text + "%'", "");
        Literal1.Text = "<div class='ketquatimkiem'>Có " + dt.Rows.Count + " kết quả được tìm thấy.</div>";
        gvQuanly.DataSource = dt;
        gvQuanly.DataBind();
    }
    protected void gvQuanly_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvQuanly.PageIndex = e.NewPageIndex;   //trang hien tai
        
        LoadData();
    }
}